/*
 * @(#)AlarmNoticeBeanCountLogImpl.java   1.0  2022年3月16日
 * 
 * Copyright (c)	2014-2020. All Rights Reserved.	GuangZhou hhmk Technology Company LTD.
 */
package com.swift.monitor.core.alarm;

import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.swift.core.log.LogPrintlnUtil;
import com.swift.core.log.LogPrintlnUtil.LogTitle;
import com.swift.core.log.LogPrintlnUtil.LogUnit;
import com.swift.monitor.core.point.AlarmLevel;
import com.swift.monitor.core.point.BeanCountListPoint;

/**
 * 添加说明 
 * @author zhengjiajin
 * @version 1.0 2022年3月16日
 */
@Component
public class AlarmNoticeBeanCountListLogImpl implements AlarmNotice<BeanCountListPoint>{

    private static final Logger log = LoggerFactory.getLogger(AlarmNoticeBeanCountListLogImpl.class);
    /** 
     * @see com.swift.monitor.core.alarm.AlarmNotice#alarm(com.swift.monitor.core.point.Point)
     */
    @Override
    public void alarm(BeanCountListPoint t) {
        List<LogTitle> logTitleList = new ArrayList<LogTitle>();
        logTitleList.add(new LogTitle("className", 30, "className",false));
        logTitleList.add(new LogTitle("methedName", 30, "methedName",false));
        logTitleList.add(new LogTitle("countNum", 10, "countNum"));
        logTitleList.add(new LogTitle("aveTime", 20, "aveTime"));
        logTitleList.add(new LogTitle("maxTime", 20, "maxTime"));
        logTitleList.add(new LogTitle("throwNum", 20, "throwNum"));
        logTitleList.add(new LogTitle("ratio", 10, "ratio",LogUnit.PRE));
        String logInfo = LogPrintlnUtil.println(t.getAlarmInfo(),logTitleList, t.getCountPoint());
        if (AlarmLevel.ERROR.equals(t.getLevel())) {
            log.error(logInfo);
        }
        if (AlarmLevel.WARN.equals(t.getLevel())) {
            log.warn(logInfo);
        }
        if (AlarmLevel.INFO.equals(t.getLevel())) {
            log.info(logInfo);
        }
    }

}
